﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Manager.App_Code.DAL;
using Manager.App_Code.IDAL;

namespace Manager.FormMain
{
    public partial class Frm_BarButton_SoDangKyKhachDoan : DevExpress.XtraEditors.XtraForm
    {
        public Frm_BarButton_SoDangKyKhachDoan()
        {
            InitializeComponent();
        }

        private void Frm_BarButton_SoDangKyKhachDoan_Load(object sender, EventArgs e)
        {
            dateTuNgay.Text = DateTime.Now.ToShortDateString();
            dateDenNgay.Text = DateTime.Now.ToShortDateString();
            INhomKhachDatPhong inhomkhach = new NhomKhachDatPhongDAL();
            gridNhomKhach.DataSource = inhomkhach.GetlistNhomKhachDatPhong();

            int index = gridView3.FocusedRowHandle;
            IPhieuDangKy iphieudk = new PhieuDangKyDAL();
            if (index >= 0)
            {
                gridPhieuDat.DataSource = iphieudk.GetListPhieuDKByMaNhom(long.Parse(gridView3.GetRowCellValue(index, MaNhomKhach).ToString()));
            }


            int index1 = gridView1.FocusedRowHandle;

            IChiTietPhieuDangKy ichitetphieu = new ChiTietPhieuDangKyDAL();
            if (index1 >= 0)
            {
                gridKhachHang.DataSource = ichitetphieu.GetAllPhieuDKByMaPhieu(long.Parse(gridView1.GetRowCellValue(index1, MaPhieu).ToString()));
            }

        }

        private void gridNhomKhach_Click(object sender, EventArgs e)
        {
            int index = gridView3.FocusedRowHandle;
            IPhieuDangKy iphieudk = new PhieuDangKyDAL();
            if (index >= 0)
            {
                gridPhieuDat.DataSource = iphieudk.GetListPhieuDKByMaNhom(long.Parse(gridView3.GetRowCellValue(index, MaNhomKhach).ToString()));
            }

            int index1 = gridView1.FocusedRowHandle;

            IChiTietPhieuDangKy ichitetphieu = new ChiTietPhieuDangKyDAL();
            if (index1 >= 0)
            {
                gridKhachHang.DataSource = ichitetphieu.GetAllPhieuDKByMaPhieu(long.Parse(gridView1.GetRowCellValue(index1, MaPhieu).ToString()));
            }


        }

        private void gridPhieuDat_Click(object sender, EventArgs e)
        {
            int index = gridView1.FocusedRowHandle;

            IChiTietPhieuDangKy ichitetphieu = new ChiTietPhieuDangKyDAL();

            gridKhachHang.DataSource = ichitetphieu.GetAllPhieuDKByMaPhieu(long.Parse(gridView1.GetRowCellValue(index, MaPhieu).ToString()));

        }
    }
}